<template>
    <hd-login :loginStyle="loginStyle" :fun="beforeLogin"></hd-login>
</template>

<script>
import { mapActions } from 'vuex'
import { getOfficeInfo } from '@/api/record'

export default {
  data () {
    return {
      loginStyle: {
        // backgroundImage: 'url(https://house-manager.oss-cn-qingdao.aliyuncs.com/government/government_bg2.jpg)'
        backgroundImage: 'url(https://house-manager.oss-cn-qingdao.aliyuncs.com/government/government_bg.png)'
      }
    }
  },
  methods: {
    ...mapActions([
      'setUserInfo',
      'getUserInfo'
    ]),
    getOfficeInfoAction () {
      getOfficeInfo().then(res => {
        if (res.data.errcode === 0) {
          window.localStorage.removeItem('record_number')
          window.localStorage.setItem('record_number', res.data.data.record_number)
        }
      })
    },
    async beforeLogin () {
      let rest = await this.getUserInfo()
      if (rest.errcode === 0) {
        // let _this = this
        // setTimeout(function () {
        //   _this.getOfficeInfoAction()
        // }, 500)
        return true
      } else {
        this.$Message.error('获取用户信息失败')
        return false
      }
    }
  }
}
</script>
